package com.yet.kotlinapp.modules.regist

import android.text.TextUtils
import com.google.android.material.resources.TextAppearance
import com.yet.kotlinapp.modules.regist.inter.RegistPresenter
import com.yet.kotlinapp.modules.regist.inter.RegistView

/**
 *
 * @ProjectName: Kotlin app
 * @Package: com.yet.kotlinapp.modules.regist
 * @ClassName: RegistPresentImp
 * @Description: java类作用描述
 * @Author: liys
 * @CreateDate: 2021/8/30 10:46
 * @UpdateUser: 更新者
 * @UpdateDate: 2021/8/30 10:46
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
class RegistPresentImp(var view:RegistView):RegistPresenter,RegistPresenter.onRegistCallback {

    var registModel:RegistModelImp= RegistModelImp()

    override fun registAction(user: String, pw: String, pw2: String) {
        if(TextUtils.isEmpty(pw)||TextUtils.isEmpty(pw)||TextUtils.isEmpty(pw2)){
            view.onFail("用户名或密码不能为空")
            return
        }
        if(pw == pw2){
            registModel.onRegist(user,pw,pw2,this)
        }else{
            view.onFail("两次密码输入不一致")
        }
    }

    override fun onSuccess() {
        view.onSuccess()
    }

    override fun onFairl(msg: String) {
      view.onFail(msg)
    }


}